package com.yc.http.tomcat.impl;

import com.yc.http.tomcat.HttpServletRequest;
import com.yc.http.tomcat.HttpServletResponse;
import com.yc.http.tomcat.ServletException;

import java.io.IOException;
import java.io.PrintWriter;

public class LikesServlet extends HttpServletImpl{

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String[] likes = request.getParameterValues("like");
        out.append("<ol>");
        for (String like : likes) {
            out.append("<li>").append(like).println("</li>");
        }
        out.append("</ol>");
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        doGet(request, response);
    }
}
